// JavaScript Document

$(".photoslider-1click").sliderkit({
    auto: false,
    circular: true,
    shownavitems: 8,
    panelfx: "sliding",
    panelfxspeed: 1000,
    panelfxeasing: "easeOutExpo"
});

// Carousel > Demo #1
$("#carousel-demo1").sliderkit({
    auto: false,
    circular: true,
    shownavitems: 1,
    panelfx: "sliding",
    start: 1,
    scrolleasing: "easeOutBack"
});

$("#carousel-demo5").sliderkit({
    auto: false,
    autospeed: 4000,
    shownavitems: 4,
    circular: true,
    fastchange: false,
    scrolleasing: "easeOutBack", //"easeOutBounce, easeOutBack", "easeOutExpo"
    scrollspeed: 1000
});

$("#standardPhotosgallery").sliderkit({
    shownavitems: 2,
    //navfx:"none",
    panelbtnshover: true,
    auto: false,
    circular: true,
    navscrollatend: true
});

$(document).scroll(function() {
    if ($(document).scrollTop() >= 180) {
        $('.navigation').animate().addClass('fixedNavigation');
        $('.navigationLogo').stop().animate({width: '56px', marginTop: '2px', marginRight: '2px'});
        $('.container').stop().animate({paddingTop: '55px'});
    }
    else {
        $('.navigation').animate().removeClass('fixedNavigation');
        $('.navigationLogo').stop().animate({width: '0', marginTop: '0', marginRight: '0'});
        $('.container').stop().animate({paddingTop: '0'});
    }
});

$('.navigation li').hover(function(e) {
    $('.submenu', this).stop().slideToggle('fast');
});

for ($i = 5; $i < 8; $i++) {
    $('.sliderkit .sliderkit-nav-clip ul li').eq($i).addClass('up');
}

$(function() {
    var settings = {
        showArrows: false,
        autoReinitialise: true
    };
    var pane = $('.scroll-pane')
    pane.jScrollPane(settings);
});

$(document).ready(function() {
    $('.importantNewsTab li').click(function() {
        if ($('a', this).hasClass('active')) {
            return false;
        }
        else {
            $activeTab = $('.importantNewsTab li.active a').attr('href');
            $toLoad = $('a', this).attr('href');
            $($activeTab).fadeOut('fast', loadContent);
            $('.importantNewsTab li').removeClass('active');
            $(this).addClass('active');
            return false;
        }
        function loadContent() {
            $($toLoad).fadeIn(500);
        }
    });

    /* share bars */
    $LOSNumber = ($('.LOS_gplus').length);

    for ($i = 0; $i < $LOSNumber; $i++) {
        calculateShares('LOS_gplus', $('.LOS_gplus').eq($i).attr('onclick'), $i);
        calculateShares('LOS_twitter', $('.LOS_twitter').eq($i).attr('onclick'), $i);
        calculateShares('LOS_facebook', $('.LOS_facebook').eq($i).attr('onclick'), $i);
    }

    /*------------ full screen slider --------------------*/
    //Thumbnailer.config.shaderOpacity = 1;
//    var tn1 = $('.mygallery').tn3({
//        skinDir: "skins",
//        imageClick: "fullscreen",
//        image: {
//            maxZoom: 1.5,
//            crop: true,
//            clickEvent: "dblclick",
//            transitions: [{
//                    type: "blinds"
//                }, {
//                    type: "grid"
//                }, {
//                    type: "grid",
//                    duration: 460,
//                    easing: "easeInQuad",
//                    gridX: 1,
//                    gridY: 8,
//                    // flat, diagonal, circle, random
//                    sort: "random",
//                    sortReverse: false,
//                    diagonalStart: "bl",
//                    // fade, scale
//                    method: "scale",
//                    partDuration: 360,
//                    partEasing: "easeOutSine",
//                    partDirection: "left"
//                }]
//        }
//    });
    /*---------- full screen slider end --------------------*/

});


/* top title channged like instagram */
$('.socialAndVideosArea').on('scroll', function(e) {

    var lastOnSocialAreaHeight = parseInt($('.LastOnSocialArea').height());
    var socialAndVideoScroll = -1 * (parseInt($('.socialAndVideosArea .jspPane').css('top')));
    $onSocailTitle = $('#onSocailTitle').html();
    $LatestVideosTitle = $('#LatestVideosTitle').html();

    if (socialAndVideoScroll > lastOnSocialAreaHeight) {
        $('.topSocialAndVideos').html($LatestVideosTitle);
    }
    else {
        $('.topSocialAndVideos').html($onSocailTitle);
    }
});

$('.toTop').click(function() {
    $('body,html').animate({
        scrollTop: 0
    }, 800);
    return false;
});

/* right menu effects */
$('.closeRM span').click(function(e) {
    $('.rightMenu').slideUp('slow', 'easeOutBack');
    $('.openRM').show('fast');
});
$('.openRM').click(function(e) {
    $('.rightMenu').slideDown('slow', 'easeOutBack');
    $('.openRM').hide('fast');
});

/* highlights effects home page */
function Highlight() {
    $('.sectionOneNewBox').hover(function() {
        $('.sectionNewContent', this).css('height', '120px');
        $('.sideBar').stop(true, true).animate({opacity: 0.3}, 300);
        $('.sliderkit').stop(true, true).animate({opacity: 0.3}, 300);
        $('.sectionsAreaCategories').stop(true, true).animate({opacity: 0.3}, 300);
        $('.sectionOneNewBox').stop(true, true).animate({opacity: 0.3}, 300);
        $('.homeadvsLeaderBoard').stop(true, true).animate({opacity: 0.3}, 300);
        $(this).stop(true, true).animate({opacity: 1}, 300);

        $('.sectionNewInfo', this).stop(true, true).hide(300);
        $('.tags', this).stop(true, true).hide(300);
        $('.rating-static', this).stop(true, true).hide(300);
        $('.sectionNewContent h3', this).stop(true, true).animate({height: '110px'});
    }, function() {
        $('.sectionNewContent', this).css('height', '90px');
        $('.sideBar').stop(true, true).animate({opacity: 1});
        $('.sliderkit').stop(true, true).animate({opacity: 1});
        $('.sectionsAreaCategories').stop(true, true).animate({opacity: 1});
        $('.sectionOneNewBox').stop(true, true).animate({opacity: 1});
        $('.homeadvsLeaderBoard').stop(true, true).animate({opacity: 1});

        $('.sectionNewInfo', this).stop(true, true).show(300);
        $('.tags', this).stop(true, true).show(300);
        $('.rating-static', this).stop(true, true).show(300);
        $('.sectionNewContent h3', this).stop(true, true).animate({height: '36px'});
    });
}


$(window).scroll(function(e) {
    if ($('.socialShare').length) {
        if ($(this).scrollTop() > $(".socialShare").offset().top && $(this).scrollTop()) {
            $(".rightSocialShare").addClass('rightSocialShare_fixed');
        }
        else {
            $(".rightSocialShare").removeClass('rightSocialShare_fixed');
        }
    }
    else {
    }
});

/* sport slider animation */
$('.sliderVideo').hover(function() {
    $('.sliderImage').stop().animate({width: '165px'});
    $(this).stop().animate({width: '385px'});
}, function() {
    $('.sliderImage').stop().animate({width: '385px'});
    $(this).stop().animate({width: '165px'});
});

$('.openSportMenu').click(function(e) {
    $('.sportMenu').stop().slideToggle('slow');
});

function calculateShares($socialname, $precentage, $i) {
    $('.' + $socialname + ' .LOSImg').eq($i).css('bottom', $precentage + '%');
    $('.' + $socialname + ' .LOSSharePrecentage').eq($i).css('height', $precentage + '%');
}

/* map popup */
$(function($) {
    var currentMousePos = {x: -1, y: -1};
    $(document).mousemove(function(event) {
        currentMousePos.x = event.pageX;
        currentMousePos.y = event.pageY;
    });
    $('#govs').click(function(e) {
        $('#tooltipMap').css('top', currentMousePos.y - 109).css('left', currentMousePos.x - 470).css('display', 'block');
    });

    $('.closeTTM').click(function(e) {
        $('#tooltipMap').fadeOut('fast');
    });
});